<?php
/*
 * Created on 08.04.2007
 * @filesource: admin.schichtplan.php
 * @author: Nikolai Plath
 */

   defined( '_VALID_MOS' ) or die( 'Direct Access to this script is not allowed');
   require_once($mainframe->getPath('class'));
   require_once($mainframe->getPath('admin_html'));
   $id = mosGetParam( $_REQUEST, 'cid', array(0) );
   if (!is_array( $id )) {
      $id = array(0);
   }
   if ((!$act || $act == 'all') && !$task)
      $task="listItems";
   switch ($task) {
      case "listItems": listItems($option); break;
      case "edit": edit($option, $id[0]); break;
     case "new": edit($option, ''); break;
     case "save": save($option); break;
     case "delete": delete($option, $id); break;
     case "publish": publish($option, '1', $id); break;
     case "unpublish": publish($option, '0', $id); break;
  }
  function listItems($option) {
     global $database;
     $database->setQuery("SELECT * FROM #__schichtplan"
                         ." ORDER BY id");
     $rows = $database->loadObjectList();
     HTML_Schichtplan::listItems($option, $rows);
}

function edit($option, $uid) {
     global $database;
     $row = new mosSchichtplan($database);
     $row->load($uid);
     HTML_Schichtplan::edit( $option, $row);
  }
  function save($option) {
     global $database;
     $row = new mosSchichtplan($database);
     $row->bind($_POST);
     $row->store();
     mosRedirect("index2.php?option=$option", "Saved");
  }
  function delete( $option, $cid ) {
     global $database;
     $cids = implode( ',', $cid );
     $database->setQuery( "DELETE FROM #__schichtplan "
                         ."WHERE id IN ($cids)" );
     $database->query();
     mosRedirect( "index2.php?option=$option" );
  }
  function publish( $option, $publish ,$cid ) {
     global $database;
    $cids = implode( ',', $cid );
     $database->setQuery( "UPDATE #__schichtplan "
                         ."SET published='$publish' "
                         ."WHERE id IN ($cids)" );
     $database->query();
     mosRedirect( "index2.php?option=$option" );
  }
?>
